<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/ydui.css" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/base.css" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/style.css" />
    <link rel="stylesheet" href="/${BasePath}/static/mobile/css/swiper.min.css" />  
    <title>半岛云</title>  
</head>
<body>
	<input type="hidden" id="active" value="gwc">
	<div class="wrap">
		<!--标题栏-->
		<div class="gw_top">
			<div class="address">

				<i class="icons">&#xe652;</i>
				<p>地址:<#if add!="0">${add.provance!""}${add.city!""}${add.area!""}${add.address!""}<#else>暂无地址<a href="/${BasePath}/main/insertAddress">前去添加</a></#if></p>
			</div>
			<a href="javascript:;">修改</a>
		</div>

		<!--主体区域-->
		<div class="container" style="padding-bottom:60px">	
	        <ul class="gw_list">
	        	<li>
	        		<dl>
	        			<dt><span>购买的商品</span></dt>
	        			<#list car as shopCart>
	        			<dd>
	        				<div class="gwinfo">
		        				<img class="gw_img" src="${shopCart.productCover!''}"/>
		        				<h4><p>${shopCart.productName!""}</p></h4>
		        				<p><span class="price">￥${shopCart.productPrice!""}</span></p>
		        				<div class="addminus">
		        					<span class="number">${shopCart.productNum!""}</span>
		        				</div>
	        				</div>
	        			</dd>
	        			</#list>
	        		</dl>
	        	</li>
	        </ul>
		</div>
	    
	    
	   <!--结算--> 
	   <div class="pay">
	   	   <div class="js paytab" style="width:100%">
	   	   	   <span class="yf">不含运费</span>
		   	   <p>合计:<span>￥0</span></p>
		   	   <a href="javascript:;" data-ydui-actionsheet="{target:'#actionSheet',closeElement:'#cancel'}">支付</a>
	   	   </div>
	   </div>
		<div class="m-actionsheet" id="actionSheet">
		    <a href="javascript:;" class="actionsheet-item zfb">支付宝支付</a>
		    <a href="javascript:;" class="actionsheet-item wx">微信支付</a>
		    <a href="javascript:;" class="actionsheet-item wxzz">已微信转账</a>
		    <a href="javascript:;" class="actionsheet-action" id="cancel">取消</a>
		</div> 
	  <!--选择地址-->
	  <div class="zz">
	  	<div class="select_window">
	  		<h2>选择地址<i class="icons">&#xe655;</i></h2>
	  		<ul class="address_list">
	  		<#if add!="0">
		  		<#list addList as adds>
		  			<li data-id="${adds.id!''}" class="checks <#if adds.id==add.id>active</#if>" >
		  				<div class="dzcheck"><i class="icons unchecked">&#xe619;</i><i class="icons checked">&#xe607;</i></div>
		  				<h4><span>${adds.name!""}</span><span>${adds.phone!""}</span></h4>
		  				<p>${adds.provance!""}${adds.city!""}${adds.area!""}${adds.address!""}</p>
		  			</li>
		  		</#list>
	  		</#if>	
	  		</ul>
	  		<ul class="address_tab">
	  			<li><a href="/${BasePath}/main/insertAddress">新建地址</a></li>
	  			<li><a href="javascript:;">确定</a></li>
	  		</ul>
	  	</div>
	  </div>
	  
		<!--导航栏-->
        <#include "/common/foot.html">
	</div>
</body>
<script type="text/javascript" src="/${BasePath}/static/mobile/js/ydui.flexible.js"></script>
<script type="text/javascript" src="/${BasePath}/static/mobile/js/ydui.js"></script>
<script type="text/javascript">
    $(function(){
	    //统计
	    function totals(){
	    	var num=0;
	    	$(".gwinfo").each(function(index,item){
	    		num += ($(item).find(".price").text().substring(1,$(item).find(".price").text().length)*$(item).find(".number").text());
	    	})
	    	return num
	    }
	    function sum(){
	    	$(".pay p span").text("￥"+totals())
	    }
	    
	    sum()
 
	    
	    /*收货地址*/
	    $(".gw_top a").click(function(){
	    	$(".zz").fadeIn()
	    })
	    $("body").on("click",".select_window h2 i",function(){
	    	$(".zz").fadeOut()
	    })
	    $("body").on("click",".address_tab li:last-child a",function(){
	    	$(".address p").text($(".select_window li.active p").text())
	    	$(".zz").fadeOut()
	    })
	    $("body").on("click",".select_window li",function(){
	    	$(this).addClass("active").siblings().removeClass();
	    })
	    
	    //支付宝
	    $(".zfb").click(function(){
	    	YDUI.dialog.confirm('提示',  '前去付款！',  function () {
	            var addressId;
		    	$(".checks.active").each(function(index,item){
		    		addressId = $(item).attr('data-id');
		    	})
			    var form = $("<form>");
	 		    form.attr("style","display:none");
	 		    form.attr("target","");
	 		    form.attr("method","post");
	 		    //请求地址
	 		    form.attr("action","/${BasePath}/order/orderSettlement");
	 		    var input1 = $("<input>");
	 		    var input2 = $("<input>");
	 		    var input3 = $("<input>");
	 		    input1.attr("type","hidden");
	 		    input1.attr("name","addressId");
	 		    input1.attr("value",addressId);
	 		    input2.attr("type","hidden");
	 		    input2.attr("name","orderId");
	 		    input2.attr("value",${orderId!''});
	 		    input3.attr("type","hidden");
	 		    input3.attr("name","cartId");
	 		    input3.attr("value","${cartId!''}");
	 		    $("body").append(form);
	 		    form.append(input1);
	 		    form.append(input2);
	 		    form.append(input3);
	 		    form.submit();
	 		    form.remove();   
	    	});
	    })	 

	    //微信
	    $(".wxzz").click(function(){
	    	YDUI.dialog.confirm('提示','确认已经转账！',  function () {
	            var addressId;
		    	$(".checks.active").each(function(index,item){
		    		addressId = $(item).attr('data-id');
		    	})
	            $.ajax({
	                cache: true,
	                type: "POST",
	                url: "/${BasePath}/order/wxzzOrder",
	                data: {"addressId":addressId,"id":${orderId!''},"cartId":"${cartId!''}"},
	                async: false,
	                error: function(request) {
	                	YDUI.dialog.alert('系统错误，请联系管理员！');
	                },
	                success: function(data) {
	                	if(data.code=="1"){
	                		YDUI.dialog.alert(data.msg, function(){
	                			window.location.href="/${BasePath}/order/shopCart";   
	                		});
	                	}else{
	                		YDUI.dialog.alert(data.msg);
	                	}
	                	
	                }
	            });		    	
	    	});
	    })	
	    
	    	    //支付宝
	    $(".wx").click(function(){
	    	YDUI.dialog.alert('微信支付暂未开通！');
	    })	
	})
</script>
</html>